﻿/*
版权所有：版权所有(C) 2011，刘建新
文件编号：M01_Emailsever.cs
文件名称：Emailsever.cs
系统编号：Z0003007
系统名称：通用办公系统
模块编号：M01
模块名称：信息发布
设计文档：IOA_M01信息发布XDE建模.mdx
完成日期：2011-01-13
作　　者：
内容摘要：表[EmailSever]对应的实体类
*/

using System;
using System.Collections;
using System.Data;


namespace Eis51.CampanyCMS.Model.Bus
{
		/// <summary>
		/// 类 编 号：
		/// 类 名 称：Emailsever
		/// 内容摘要：
		/// </summary>
		
		[Serializable]
		public class Emailsever : BaseModel
		{
		#region 自动生成代码
		
			#region 重载Equals/GetHashCode
			/// <summary>
			/// 重载Equals			
			/// </summary>
			public override bool Equals (Object obj)
			{
				if (obj != null && obj is Emailsever)
				{
					if (obj == this)
						return true;
					Emailsever castObj = (Emailsever)obj; 
					
					if (!this.m_Msgid.Equals(castObj.Msgid))
						return false;
						
					if (!this.m_Code.Equals(castObj.Code))
						return false;
						
					if (!this.m_Emailfrom.Equals(castObj.Emailfrom))
						return false;
						
					if (!this.m_Emailto.Equals(castObj.Emailto))
						return false;
						
					if (!this.m_Password.Equals(castObj.Password))
						return false;
						
					if (!this.m_Issend.Equals(castObj.Issend))
						return false;
						
					if (!this.m_Smtp.Equals(castObj.Smtp))
						return false;
						
					if (!this.m_Createby.Equals(castObj.Createby))
						return false;
						
					return true;
				}
				return false;
			}
			
			/// <summary>
			/// 重载GetHashCode
			/// </summary>
			public override int GetHashCode()
			{
					int hash = 0;					
					
					hash = hash <<  8;
					if ((object)m_Msgid != null)
					{
						hash = hash ^ m_Msgid.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Code != null)
					{
						hash = hash ^ m_Code.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Emailfrom != null)
					{
						hash = hash ^ m_Emailfrom.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Emailto != null)
					{
						hash = hash ^ m_Emailto.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Password != null)
					{
						hash = hash ^ m_Password.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Issend != null)
					{
						hash = hash ^ m_Issend.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Smtp != null)
					{
						hash = hash ^ m_Smtp.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Createby != null)
					{
						hash = hash ^ m_Createby.GetHashCode();
					}
						
					return hash; 
			}
			#endregion
			
			public Emailsever()
			{
				MarkNew();
			}						
			
			public Emailsever GetOldValue()
			{
				return OldValue as Emailsever;
			}
		
		#region Msgid属性
			private int m_Msgid = 0;
			/// <summary>
			/// 属性名称： Msgid
			/// 内容摘要： DB列名：MsgId[]
			///            DB类型：int
			/// </summary>
			public int Msgid
			{
				get
					{
						return m_Msgid;
					}
				set
					{
						if (m_Msgid as object == null || !m_Msgid.Equals(value))
						{
							m_Msgid = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Code属性
			private string m_Code = String.Empty;
			/// <summary>
			/// 属性名称： Code
			/// 内容摘要： DB列名：Code[]
			///            DB类型：string
			/// </summary>
			public string Code
			{
				get
					{
						return m_Code;
					}
				set
					{
						if (m_Code as object == null || !m_Code.Equals(value))
						{
							m_Code = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Emailfrom属性
			private string m_Emailfrom = String.Empty;
			/// <summary>
			/// 属性名称： Emailfrom
			/// 内容摘要： DB列名：EmailFrom[]
			///            DB类型：string
			/// </summary>
			public string Emailfrom
			{
				get
					{
						return m_Emailfrom;
					}
				set
					{
						if (m_Emailfrom as object == null || !m_Emailfrom.Equals(value))
						{
							m_Emailfrom = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Emailto属性
			private string m_Emailto = String.Empty;
			/// <summary>
			/// 属性名称： Emailto
			/// 内容摘要： DB列名：EmailTo[]
			///            DB类型：string
			/// </summary>
			public string Emailto
			{
				get
					{
						return m_Emailto;
					}
				set
					{
						if (m_Emailto as object == null || !m_Emailto.Equals(value))
						{
							m_Emailto = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Password属性
			private string m_Password = String.Empty;
			/// <summary>
			/// 属性名称： Password
			/// 内容摘要： DB列名：PassWord[]
			///            DB类型：string
			/// </summary>
			public string Password
			{
				get
					{
						return m_Password;
					}
				set
					{
						if (m_Password as object == null || !m_Password.Equals(value))
						{
							m_Password = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Issend属性
			private int m_Issend = 0;
			/// <summary>
			/// 属性名称： Issend
			/// 内容摘要： DB列名：IsSend[]
			///            DB类型：int
			/// </summary>
			public int Issend
			{
				get
					{
						return m_Issend;
					}
				set
					{
						if (m_Issend as object == null || !m_Issend.Equals(value))
						{
							m_Issend = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Smtp属性
			private string m_Smtp = String.Empty;
			/// <summary>
			/// 属性名称： Smtp
			/// 内容摘要： DB列名：Smtp[]
			///            DB类型：string
			/// </summary>
			public string Smtp
			{
				get
					{
						return m_Smtp;
					}
				set
					{
						if (m_Smtp as object == null || !m_Smtp.Equals(value))
						{
							m_Smtp = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Createby属性
			private string m_Createby = String.Empty;
			/// <summary>
			/// 属性名称： Createby
			/// 内容摘要： DB列名：CreateBy[]
			///            DB类型：string
			/// </summary>
			public string Createby
			{
				get
					{
						return m_Createby;
					}
				set
					{
						if (m_Createby as object == null || !m_Createby.Equals(value))
						{
							m_Createby = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region static CreateDataTable/FillDataRow/DataRow2Obj/Dt2Objs/FillDataTable
			/// <summary>
			/// 得到实体对应的DataTable
			/// </summary>
			/// <param name="tableName">表名</param>
			/// <param name="cne">列名映射选择:DB列名或属性名</param>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable(string tableName,ColumnNameEnum cne)
			{
				DataTable dtResult = new DataTable(tableName);
			
				if (cne == ColumnNameEnum.DBName)
				{
					dtResult.Columns.Add(new DataColumn("MsgId",typeof(int)));
					dtResult.Columns.Add(new DataColumn("Code",typeof(string)));
					dtResult.Columns.Add(new DataColumn("EmailFrom",typeof(string)));
					dtResult.Columns.Add(new DataColumn("EmailTo",typeof(string)));
					dtResult.Columns.Add(new DataColumn("PassWord",typeof(string)));
					dtResult.Columns.Add(new DataColumn("IsSend",typeof(int)));
					dtResult.Columns.Add(new DataColumn("Smtp",typeof(string)));
					dtResult.Columns.Add(new DataColumn("CreateBy",typeof(string)));
				}
				else if (cne == ColumnNameEnum.PropertyName)
				{
					dtResult.Columns.Add(new DataColumn("Msgid",typeof(int)));
					dtResult.Columns.Add(new DataColumn("Code",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Emailfrom",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Emailto",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Password",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Issend",typeof(int)));
					dtResult.Columns.Add(new DataColumn("Smtp",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Createby",typeof(string)));
				}
				return dtResult;
			}
			
			/// <summary>
			/// 得到实体对应的DataTable
			/// </summary>
			/// <param name="cne">列名映射选择:DB列名或属性名</param>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable(ColumnNameEnum cne)
			{
				return CreateDataTable(null,cne);
			}

			/// <summary>
			/// 得到实体对应的DataTable(默认列名映射为属性名)
			/// </summary>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable()
			{
				return CreateDataTable(ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 用当前对象值填充DaraRow
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			/// <param name="cne">dr的列名映射方式:DB列名或属性名</param>
			public void FillDataRow(DataRow dr,ColumnNameEnum cne)
			{
				if (dr == null)
				{
					throw new ArgumentNullException("dr");
				}
				if (ColumnNameEnum.DBName == cne)
				{
					dr["MsgId"] = this.Msgid;
					dr["Code"] = this.Code;
					dr["EmailFrom"] = this.Emailfrom;
					dr["EmailTo"] = this.Emailto;
					dr["PassWord"] = this.Password;
					dr["IsSend"] = this.Issend;
					dr["Smtp"] = this.Smtp;
					dr["CreateBy"] = this.Createby;
				}
				else if (ColumnNameEnum.PropertyName == cne)
				{
					dr["Msgid"] = this.Msgid;
					dr["Code"] = this.Code;
					dr["Emailfrom"] = this.Emailfrom;
					dr["Emailto"] = this.Emailto;
					dr["Password"] = this.Password;
					dr["Issend"] = this.Issend;
					dr["Smtp"] = this.Smtp;
					dr["Createby"] = this.Createby;					
				}
			}
			
			/// <summary>
			/// 用当前对象值填充DaraRow(默认列名映射为属性名)
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			public void FillDataRow(DataRow dr)
			{
				this.FillDataRow(dr,ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 将DataRow转换成Emailsever对象
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			/// <param name="cne">dr的列名映射方式:DB列名或属性名</param>
			/// <returns>Emailsever对象</returns>
			public static Emailsever Dr2Obj(DataRow dr,ColumnNameEnum cne)
			{
				if (dr == null)
				{
					throw new ArgumentNullException("dr");
				}
				Emailsever obj = new Emailsever();
				if (ColumnNameEnum.DBName == cne)
				{
					obj.Msgid = (dr["MsgId"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["MsgId"],typeof(int));
					obj.Code = (dr["Code"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Code"],typeof(string));
					obj.Emailfrom = (dr["EmailFrom"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["EmailFrom"],typeof(string));
					obj.Emailto = (dr["EmailTo"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["EmailTo"],typeof(string));
					obj.Password = (dr["PassWord"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["PassWord"],typeof(string));
					obj.Issend = (dr["IsSend"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["IsSend"],typeof(int));
					obj.Smtp = (dr["Smtp"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Smtp"],typeof(string));
					obj.Createby = (dr["CreateBy"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["CreateBy"],typeof(string));
				}
				else if (ColumnNameEnum.PropertyName == cne)
				{
					obj.Msgid = (dr["Msgid"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["Msgid"],typeof(int));
					obj.Code = (dr["Code"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Code"],typeof(string));
					obj.Emailfrom = (dr["Emailfrom"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Emailfrom"],typeof(string));
					obj.Emailto = (dr["Emailto"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Emailto"],typeof(string));
					obj.Password = (dr["Password"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Password"],typeof(string));
					obj.Issend = (dr["Issend"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["Issend"],typeof(int));
					obj.Smtp = (dr["Smtp"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Smtp"],typeof(string));
					obj.Createby = (dr["Createby"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Createby"],typeof(string));		
				}
				
				return obj;
			}
			
			/// <summary>
			/// 将DataRow转换成Emailsever对象(默认列名映射为属性名)
			/// </summary>
			/// <returns>Emailsever对象</returns>
			public static Emailsever Dr2Obj(DataRow dr)
			{
				return Dr2Obj(dr,ColumnNameEnum.DBName);
			}
			
			/// <summary>
			/// 将DataTabe转换成的Emailsever对象集合
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="cne">dt的列名映射方式:DB列名或属性名</param>
			/// <returns>Emailsever对象的集合</returns>
			public static IList Dt2Objs(DataTable dt,ColumnNameEnum cne)
			{
				if (dt == null)
				{
					throw new ArgumentNullException("dt");
				}
				
				ArrayList alResult = new ArrayList();
				
				foreach(DataRow dr in dt.Rows)
				{
					alResult.Add(Dr2Obj(dr,cne));
				}
				
				return alResult;
			}

			/// <summary>
			/// 将DataTabe转换成的Emailsever对象集合(默认列名映射为属性名)
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <returns>Emailsever对象的集合</returns>
			public static IList Dt2Objs(DataTable dt)
			{
				return Dt2Objs(dt,ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 用objs的Emailsever对象集合填充DataTable
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="objs">Emailsever对象集合</param>
			/// <param name="cne">dt的列名映射方式:DB列名或属性名</param>
			public static void FillDataTable(DataTable dt,IList objs,ColumnNameEnum cne)
			{
				if (dt == null)
				{
					throw new ArgumentNullException("dt");
				}
				if (objs == null)
				{
					throw new ArgumentNullException("objs");
				}
				
				foreach(Emailsever obj in objs)
				{
					DataRow dr = dt.NewRow();
					obj.FillDataRow(dr,cne);
					dt.Rows.Add(dr);
				}
			}

			/// <summary>
			/// 用objs的Emailsever对象集合填充DataTable(默认列名映射为属性名)
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="objs">Emailsever对象集合</param>
			public static void FillDataTable(DataTable dt,IList objs)
			{
				FillDataTable(dt,objs,ColumnNameEnum.PropertyName);
			}
		#endregion
		
		/// <summary>
		/// 取消编辑,恢复到上次有效调用BeginEdit前的状态,并清空保留值
		/// </summary>
		public override void CancelEdit()
		{
			Emailsever old = this.OldValue as Emailsever;
			if (old != null)
			{
					this.Msgid = old.Msgid;
					this.Code = old.Code;
					this.Emailfrom = old.Emailfrom;
					this.Emailto = old.Emailto;
					this.Password = old.Password;
					this.Issend = old.Issend;
					this.Smtp = old.Smtp;
					this.Createby = old.Createby;				
				this.OldValue = null;
			}
		}
		
		
		
		
		#region Emailsever实体的内部Key类
			/// <summary>
			/// Emailsever实体的Key类
			/// </summary>
			public sealed class Key
			{
		
				private int m_Msgid;
				public int Msgid
				{
 					get 
					{ 
						 return m_Msgid; 
					}
					set 
					{ 
						m_Msgid = value;
					}
				}
		
				public Key(int pMsgid)
				{
					m_Msgid=pMsgid;

				}
			}
		#endregion
			/// <summary>
			/// 得到实体Emailsever的PK
			/// </summary>
			public Key GetKey()
			{
				return new Key(Msgid);				
			}
			
				
		#endregion
	}
}
